﻿<UserControl x:Class="FaceLight.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Loaded="UserControl_Loaded"
   >

   <Grid x:Name="LayoutRoot" Background="Black" >
      <StackPanel Width="640" Height="530">
         <TextBlock FontSize="12" Text="FaceLight - Simple Silverlight Real Time Face Detection by René Schulte for Coding4Fun" Style="{StaticResource TextBlockStyle}" HorizontalAlignment="Center" VerticalAlignment="Stretch" />
         <StackPanel >
            <StackPanel Orientation="Horizontal" Margin="0,10,0,0">
               <Border Width="480" Height="360" RenderTransformOrigin="0.5,0.5" >
                  <Border.Clip>
                     <RectangleGeometry Rect="0,0,480,360" RadiusX="10" RadiusY="10" />
                  </Border.Clip>
                  <Grid Name="GrdContent" Width="480" Height="360" >
                     <Rectangle Name="WebcamVideo" RenderTransformOrigin="0.5,0.5">
                     </Rectangle>
                     <Canvas >
                        <Image Name="ImgOverlay" Source="{Binding ElementName=TxtImageSource, Path=Text}" />
                     </Canvas>
                     <Image Name="ImgResult" />
                  </Grid>
               </Border>
               <StackPanel>
                  <Image Name="ImgSkin" Width="160" Height="120" />
                  <Image Name="ImgDilate" Width="160" Height="120" />
                  <Image Name="ImgPalette" Width="160" Height="120" />
               </StackPanel>
            </StackPanel>
            <Grid >
               <Grid.ColumnDefinitions>
                  <ColumnDefinition Width="45" />
                  <ColumnDefinition />
                  <ColumnDefinition Width="40" />
                  <ColumnDefinition Width="45" />
                  <ColumnDefinition />
                  <ColumnDefinition Width="40" />
                  <ColumnDefinition Width="45" />
                  <ColumnDefinition />
                  <ColumnDefinition Width="40" />
               </Grid.ColumnDefinitions>
               <Grid.RowDefinitions>
                  <RowDefinition Height="50"/>
                  <RowDefinition Height="25" />
                  <RowDefinition Height="25" />
               </Grid.RowDefinitions>

               <StackPanel Orientation="Horizontal" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="0" >
                     <ToggleButton Name="BtnCapture" Click="BtnCapture_Click" Margin="0,0,10,0" Height="32" BorderBrush="Red" BorderThickness="2" >
                       <ToggleButton.Content>
                           <Image Source="Data/icons/video.png" />
                       </ToggleButton.Content>
                     </ToggleButton>
                  <Button Name="BtnOpenPic" Click="BtnOpenPic_Click" Margin="0,0,10,0"  Height="32" >
                     <Button.Content>
                        <Image Source="Data/icons/Folder2.png" />
                     </Button.Content>
                  </Button>
                  <Button Name="BtnSnapshot" Click="BtnSnapshot_Click" Margin="0,0,20,0"  Height="32" >
                     <Button.Content>
                        <Image Source="Data/icons/save.png" />
                     </Button.Content>
                  </Button>
               </StackPanel>

               <ComboBox Grid.Column="2" Grid.Row="0" Grid.ColumnSpan="2" Name="Combo" Width="80" Height="25" SelectionChanged="Combo_SelectionChanged" >
                  <ComboBox.Items>
                     <ComboBoxItem Content="Image" />
                     <ComboBoxItem Content="Highlight" IsSelected="True" />
                  </ComboBox.Items>
               </ComboBox>
               <TextBox Name="TxtImageSource" Grid.Column="4" Grid.Row="0" Grid.ColumnSpan="5" Height="25" Text="Data/images/monkey.png" />

               <TextBlock Grid.Column="0" Grid.Row="1" Text="Y min" Style="{StaticResource TextBlockStyle}" HorizontalAlignment="Left" VerticalAlignment="Center" />
               <Slider Grid.Column="1" Grid.Row="1" Minimum="0" Maximum="1" Name="SldYmin" Value="{Binding SkinColorFilter.LowerThreshold.Y, Mode=TwoWay}" ValueChanged="SldYCbCr_ValueChanged" />
               <TextBlock Grid.Column="2" Grid.Row="1" Text="{Binding ElementName=SldYmin, Path=Value, StringFormat=\{0:F2\}}" Style="{StaticResource TextBlockStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" />
               <TextBlock Grid.Column="0" Grid.Row="2" Text="Y max" Style="{StaticResource TextBlockStyle}" HorizontalAlignment="Left" VerticalAlignment="Center" />
               <Slider Grid.Column="1" Grid.Row="2" Minimum="0" Maximum="1" Name="SldYmax" Value="{Binding SkinColorFilter.UpperThreshold.Y, Mode=TwoWay}" ValueChanged="SldYCbCr_ValueChanged" />
               <TextBlock Grid.Column="2" Grid.Row="2" Text="{Binding ElementName=SldYmax, Path=Value, StringFormat=\{0:F2\}}" Style="{StaticResource TextBlockStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" />

               <TextBlock Grid.Column="3" Grid.Row="1" Text="Cb min" Style="{StaticResource TextBlockStyle}" HorizontalAlignment="Left" VerticalAlignment="Center" />
               <Slider Grid.Column="4" Grid.Row="1" Minimum="-0.5" Maximum="0.5" Name="SldCbmin" Value="{Binding SkinColorFilter.LowerThreshold.Cb, Mode=TwoWay}" ValueChanged="SldYCbCr_ValueChanged" />
               <TextBlock Grid.Column="5" Grid.Row="1" Text="{Binding ElementName=SldCbmin, Path=Value, StringFormat=\{0:F2\}}" Style="{StaticResource TextBlockStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" />
               <TextBlock Grid.Column="3" Grid.Row="2" Text="Cb max" Style="{StaticResource TextBlockStyle}" HorizontalAlignment="Left" VerticalAlignment="Center" />
               <Slider Grid.Column="4" Grid.Row="2" Minimum="-0.5" Maximum="0.5" Name="SldCbmax" Value="{Binding SkinColorFilter.UpperThreshold.Cb, Mode=TwoWay}" ValueChanged="SldYCbCr_ValueChanged" />
               <TextBlock Grid.Column="5" Grid.Row="2" Text="{Binding ElementName=SldCbmax, Path=Value, StringFormat=\{0:F2\}}" Style="{StaticResource TextBlockStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" />

               <TextBlock Grid.Column="6" Grid.Row="1" Text="Cr min" Style="{StaticResource TextBlockStyle}" HorizontalAlignment="Left" VerticalAlignment="Center" />
               <Slider Grid.Column="7" Grid.Row="1" Minimum="-0.5" Maximum="0.5" Name="SldCrmin" Value="{Binding SkinColorFilter.LowerThreshold.Cr, Mode=TwoWay}" ValueChanged="SldYCbCr_ValueChanged" />
               <TextBlock Grid.Column="8" Grid.Row="1" Text="{Binding ElementName=SldCrmin, Path=Value, StringFormat=\{0:F2\}}" Style="{StaticResource TextBlockStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" />
               <TextBlock Grid.Column="6" Grid.Row="2" Text="Cr max" Style="{StaticResource TextBlockStyle}" HorizontalAlignment="Left" VerticalAlignment="Center" />
               <Slider Grid.Column="7" Grid.Row="2" Minimum="-0.5" Maximum="0.5" Name="SldCrmax" Value="{Binding SkinColorFilter.UpperThreshold.Cr, Mode=TwoWay}" ValueChanged="SldYCbCr_ValueChanged" />
               <TextBlock Grid.Column="8" Grid.Row="2" Text="{Binding ElementName=SldCrmax, Path=Value, StringFormat=\{0:F2\}}" Style="{StaticResource TextBlockStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" />

            </Grid>
         </StackPanel>
         <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" >
            <HyperlinkButton TargetName="_blank" Content="Icons by Axialis Team" NavigateUri="http://www.axialis.com/free/icons" Margin="12" Foreground="LightBlue" />
            <HyperlinkButton TargetName="_blank" Content="Monkey photo by Ethan Hein" NavigateUri="http://www.flickr.com/photos/ethanhein/2246174435/" Margin="12" Foreground="LightBlue" />
         </StackPanel>
      </StackPanel>
   </Grid>
</UserControl>
